package com.fitns.user.mapper.baseConfig;

import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.fitns.user.model.baseConfig.TbSysOrgan;

import java.util.List;
import javax.annotation.Generated;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface TbSysOrganMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TbSysOrgan> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TbSysOrganResult")
    TbSysOrgan selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TbSysOrganResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="contact_name", property="contactName", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="parant_id", property="parentId", jdbcType=JdbcType.BIGINT),
        @Result(column="create_id", property="createId", jdbcType=JdbcType.BIGINT),
        @Result(column="modify_id", property="modifyId", jdbcType=JdbcType.BIGINT),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="input_time", property="inputTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="descs", property="descs", jdbcType=JdbcType.VARCHAR)
    })
    List<TbSysOrgan> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(TbSysOrganDynamicSqlSupport.tbSysOrgan);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, TbSysOrganDynamicSqlSupport.tbSysOrgan);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, TbSysOrganDynamicSqlSupport.tbSysOrgan)
                .where(TbSysOrganDynamicSqlSupport.id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TbSysOrgan record) {
        return insert(SqlBuilder.insert(record)
                .into(TbSysOrganDynamicSqlSupport.tbSysOrgan)
                .map(TbSysOrganDynamicSqlSupport.name).toProperty("name")
                .map(TbSysOrganDynamicSqlSupport.type).toProperty("type")
                .map(TbSysOrganDynamicSqlSupport.contactName).toProperty("contactName")
                .map(TbSysOrganDynamicSqlSupport.phone).toProperty("phone")
                .map(TbSysOrganDynamicSqlSupport.address).toProperty("address")
                .map(TbSysOrganDynamicSqlSupport.parantId).toProperty("parentId")
                .map(TbSysOrganDynamicSqlSupport.createId).toProperty("createId")
                .map(TbSysOrganDynamicSqlSupport.modifyId).toProperty("modifyId")
                .map(TbSysOrganDynamicSqlSupport.modifyTime).toProperty("modifyTime")
                .map(TbSysOrganDynamicSqlSupport.inputTime).toProperty("inputTime")
                .map(TbSysOrganDynamicSqlSupport.descs).toProperty("descs")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TbSysOrgan record) {
        return insert(SqlBuilder.insert(record)
                .into(TbSysOrganDynamicSqlSupport.tbSysOrgan)
                .map(TbSysOrganDynamicSqlSupport.name).toPropertyWhenPresent("name", record::getName)
                .map(TbSysOrganDynamicSqlSupport.type).toPropertyWhenPresent("type", record::getType)
                .map(TbSysOrganDynamicSqlSupport.contactName).toPropertyWhenPresent("contactName", record::getContactName)
                .map(TbSysOrganDynamicSqlSupport.phone).toPropertyWhenPresent("phone", record::getPhone)
                .map(TbSysOrganDynamicSqlSupport.address).toPropertyWhenPresent("address", record::getAddress)
                .map(TbSysOrganDynamicSqlSupport.parantId).toPropertyWhenPresent("parentId", record::getParantId)
                .map(TbSysOrganDynamicSqlSupport.createId).toPropertyWhenPresent("createId", record::getCreateId)
                .map(TbSysOrganDynamicSqlSupport.modifyId).toPropertyWhenPresent("modifyId", record::getModifyId)
                .map(TbSysOrganDynamicSqlSupport.modifyTime).toPropertyWhenPresent("modifyTime", record::getModifyTime)
                .map(TbSysOrganDynamicSqlSupport.inputTime).toPropertyWhenPresent("inputTime", record::getInputTime)
                .map(TbSysOrganDynamicSqlSupport.descs).toPropertyWhenPresent("descs", record::getDescs)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbSysOrgan>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, TbSysOrganDynamicSqlSupport.id, TbSysOrganDynamicSqlSupport.name, TbSysOrganDynamicSqlSupport.type, TbSysOrganDynamicSqlSupport.contactName, TbSysOrganDynamicSqlSupport.phone, TbSysOrganDynamicSqlSupport.address, TbSysOrganDynamicSqlSupport.parantId, TbSysOrganDynamicSqlSupport.createId, TbSysOrganDynamicSqlSupport.modifyId, TbSysOrganDynamicSqlSupport.modifyTime, TbSysOrganDynamicSqlSupport.inputTime, TbSysOrganDynamicSqlSupport.descs)
                .from(TbSysOrganDynamicSqlSupport.tbSysOrgan);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbSysOrgan>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, TbSysOrganDynamicSqlSupport.id, TbSysOrganDynamicSqlSupport.name, TbSysOrganDynamicSqlSupport.type, TbSysOrganDynamicSqlSupport.contactName, TbSysOrganDynamicSqlSupport.phone, TbSysOrganDynamicSqlSupport.address, TbSysOrganDynamicSqlSupport.parantId, TbSysOrganDynamicSqlSupport.createId, TbSysOrganDynamicSqlSupport.modifyId, TbSysOrganDynamicSqlSupport.modifyTime, TbSysOrganDynamicSqlSupport.inputTime, TbSysOrganDynamicSqlSupport.descs)
                .from(TbSysOrganDynamicSqlSupport.tbSysOrgan);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default TbSysOrgan selectByPrimaryKey(Long id_) {
        return SelectDSL.selectWithMapper(this::selectOne, TbSysOrganDynamicSqlSupport.id, TbSysOrganDynamicSqlSupport.name, TbSysOrganDynamicSqlSupport.type, TbSysOrganDynamicSqlSupport.contactName, TbSysOrganDynamicSqlSupport.phone, TbSysOrganDynamicSqlSupport.address, TbSysOrganDynamicSqlSupport.parantId, TbSysOrganDynamicSqlSupport.createId, TbSysOrganDynamicSqlSupport.modifyId, TbSysOrganDynamicSqlSupport.modifyTime, TbSysOrganDynamicSqlSupport.inputTime, TbSysOrganDynamicSqlSupport.descs)
                .from(TbSysOrganDynamicSqlSupport.tbSysOrgan)
                .where(TbSysOrganDynamicSqlSupport.id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(TbSysOrgan record) {
        return UpdateDSL.updateWithMapper(this::update, TbSysOrganDynamicSqlSupport.tbSysOrgan)
                .set(TbSysOrganDynamicSqlSupport.name).equalTo(record::getName)
                .set(TbSysOrganDynamicSqlSupport.type).equalTo(record::getType)
                .set(TbSysOrganDynamicSqlSupport.contactName).equalTo(record::getContactName)
                .set(TbSysOrganDynamicSqlSupport.phone).equalTo(record::getPhone)
                .set(TbSysOrganDynamicSqlSupport.address).equalTo(record::getAddress)
                .set(TbSysOrganDynamicSqlSupport.parantId).equalTo(record::getParantId)
                .set(TbSysOrganDynamicSqlSupport.createId).equalTo(record::getCreateId)
                .set(TbSysOrganDynamicSqlSupport.modifyId).equalTo(record::getModifyId)
                .set(TbSysOrganDynamicSqlSupport.modifyTime).equalTo(record::getModifyTime)
                .set(TbSysOrganDynamicSqlSupport.inputTime).equalTo(record::getInputTime)
                .set(TbSysOrganDynamicSqlSupport.descs).equalTo(record::getDescs);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(TbSysOrgan record) {
        return UpdateDSL.updateWithMapper(this::update, TbSysOrganDynamicSqlSupport.tbSysOrgan)
                .set(TbSysOrganDynamicSqlSupport.name).equalToWhenPresent(record::getName)
                .set(TbSysOrganDynamicSqlSupport.type).equalToWhenPresent(record::getType)
                .set(TbSysOrganDynamicSqlSupport.contactName).equalToWhenPresent(record::getContactName)
                .set(TbSysOrganDynamicSqlSupport.phone).equalToWhenPresent(record::getPhone)
                .set(TbSysOrganDynamicSqlSupport.address).equalToWhenPresent(record::getAddress)
                .set(TbSysOrganDynamicSqlSupport.parantId).equalToWhenPresent(record::getParantId)
                .set(TbSysOrganDynamicSqlSupport.createId).equalToWhenPresent(record::getCreateId)
                .set(TbSysOrganDynamicSqlSupport.modifyId).equalToWhenPresent(record::getModifyId)
                .set(TbSysOrganDynamicSqlSupport.modifyTime).equalToWhenPresent(record::getModifyTime)
                .set(TbSysOrganDynamicSqlSupport.inputTime).equalToWhenPresent(record::getInputTime)
                .set(TbSysOrganDynamicSqlSupport.descs).equalToWhenPresent(record::getDescs);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(TbSysOrgan record) {
        return UpdateDSL.updateWithMapper(this::update, TbSysOrganDynamicSqlSupport.tbSysOrgan)
                .set(TbSysOrganDynamicSqlSupport.name).equalTo(record::getName)
                .set(TbSysOrganDynamicSqlSupport.type).equalTo(record::getType)
                .set(TbSysOrganDynamicSqlSupport.contactName).equalTo(record::getContactName)
                .set(TbSysOrganDynamicSqlSupport.phone).equalTo(record::getPhone)
                .set(TbSysOrganDynamicSqlSupport.address).equalTo(record::getAddress)
                .set(TbSysOrganDynamicSqlSupport.parantId).equalTo(record::getParantId)
                .set(TbSysOrganDynamicSqlSupport.createId).equalTo(record::getCreateId)
                .set(TbSysOrganDynamicSqlSupport.modifyId).equalTo(record::getModifyId)
                .set(TbSysOrganDynamicSqlSupport.modifyTime).equalTo(record::getModifyTime)
                .set(TbSysOrganDynamicSqlSupport.inputTime).equalTo(record::getInputTime)
                .set(TbSysOrganDynamicSqlSupport.descs).equalTo(record::getDescs)
                .where(TbSysOrganDynamicSqlSupport.id, isEqualTo(record::getId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TbSysOrgan record) {
        return UpdateDSL.updateWithMapper(this::update, TbSysOrganDynamicSqlSupport.tbSysOrgan)
                .set(TbSysOrganDynamicSqlSupport.name).equalToWhenPresent(record::getName)
                .set(TbSysOrganDynamicSqlSupport.type).equalToWhenPresent(record::getType)
                .set(TbSysOrganDynamicSqlSupport.contactName).equalToWhenPresent(record::getContactName)
                .set(TbSysOrganDynamicSqlSupport.phone).equalToWhenPresent(record::getPhone)
                .set(TbSysOrganDynamicSqlSupport.address).equalToWhenPresent(record::getAddress)
                .set(TbSysOrganDynamicSqlSupport.parantId).equalToWhenPresent(record::getParantId)
                .set(TbSysOrganDynamicSqlSupport.createId).equalToWhenPresent(record::getCreateId)
                .set(TbSysOrganDynamicSqlSupport.modifyId).equalToWhenPresent(record::getModifyId)
                .set(TbSysOrganDynamicSqlSupport.modifyTime).equalToWhenPresent(record::getModifyTime)
                .set(TbSysOrganDynamicSqlSupport.inputTime).equalToWhenPresent(record::getInputTime)
                .set(TbSysOrganDynamicSqlSupport.descs).equalToWhenPresent(record::getDescs)
                .where(TbSysOrganDynamicSqlSupport.id, isEqualTo(record::getId))
                .build()
                .execute();
    }
}